home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / Sample Code / Newton Sample Code 1.2 / Drawing / Dot2Dot-2 / Dot2Dot.text < prev    next >
Encoding:
Text File  |  1994-02-28  |  3.5 KB  |  140 lines  |  [TEXT/MPS ]

  1. /*
  2.   Dot2Dot Project Data
  3.   Copyright: © Apple Computer, Inc. 1993-1994. All Rights Reserved.
  4.  */
  5.  
  6.  
  7. refNum := OpenResFileX("Dot2Dot.rsrc");
  8.   DefConst('kMrT,GetPICTAsBits("MrT",true));
  9. CloseResFileX(refNum);
  10.  
  11. 42;
  12.  
  13. // ---- End Project Data ----
  14.  
  15.  
  16. // ---- File Dot2Dot.t ----
  17. baseView :=
  18.    {title: "Dot2Dot",
  19.     viewBounds: {top: 0, left: 0, right: 240, bottom: 336},
  20.     viewEffect: 67083429
  21.     ,
  22.     viewSetupFormScript:
  23.       func()
  24.       begin
  25.           // resize to fit on all "small" newtons.
  26.           local b := GetAppParams();
  27.           constant kMaxWidth := 240;
  28.           constant kMaxHeight := 336;
  29.           self.viewBounds := RelBounds(b.appAreaLeft, b.appAreaTop,
  30.                                                 MIN(b.appAreaWidth, kMaxWidth),
  31.                                                 MIN(b.appAreaHeight, kMaxHeight));
  32.       end,
  33.     _proto: protoApp,
  34.     debug: "baseView"
  35.    };
  36.  
  37. drawingArea := /* child of baseView */
  38.    {viewFlags: 529,
  39.     viewFormat: 336,
  40.     viewBounds: {left: 0, top: 40, right: 230, bottom: 270},
  41.     viewDrawScript:
  42.       func() // draw points based on polygon information
  43.       begin
  44.       
  45.       // then draw points based on the polygon (pensize 2)
  46.           :DrawShape(thePolygon, {penSize: 2});
  47.       end,
  48.     thePolygon: nil,
  49.     viewClickScript:
  50.       func(unit)    // detect clicks and create a polygon based on the clicking
  51.       begin
  52.       
  53.       // get global coordinates
  54.           local temp := :GlobalBox();
  55.       
  56.       // get pen down locations
  57.           newX := GetPoint(unitFirstX, unit);
  58.           newY := GetPoint(unitFirstY, unit);
  59.       
  60.       // calculate the real values (local coordinates)
  61.           newX := newX - temp.left;
  62.           newY := newY - temp.top;
  63.       
  64.       // store these points into the pointArray
  65.           pointArray := SetAdd(pointArray, newX, nil);
  66.           pointArray := SetAdd(pointArray, newY, nil);
  67.       
  68.       // build a new polygon shape
  69.          thePolygon := nil;
  70.          thePolygon := MakePolygon(pointArray);
  71.       
  72.       If length(pointArray) = 2*14 then
  73.         SetValue(self,'icon,kMrT);
  74.           
  75.       // then force redraw
  76.           :Dirty();
  77.       end,
  78.     newX: nil,
  79.     newY: nil,
  80.     pointArray: nil,
  81.     viewSetupFormScript:
  82.       func()
  83.       begin
  84.           pointArray := [];
  85.           thePolygon := MakePolygon(pointArray);
  86.       end,
  87.     eraseArea:
  88.       func()    // erase the contents of the viewbounds rect
  89.       begin
  90.           :DrawShape(MakeRect(viewbounds.top, viewBounds.left, viewBounds.bottom, viewBounds.right),
  91.                       {fillPattern: 1});
  92.       end,
  93.     ZapArray:
  94.       func()    // zap array to zero, and force a redraw (in other words erase!)
  95.       begin
  96.           SetLength(pointArray, 0);
  97.           thePolygon := MakePolygon(pointArray);
  98.           :Dirty();
  99.       end,
  100.     viewJustify: 16,
  101.     icon: GetPictAsBits("Dots", 1),
  102.     viewclass: 76,
  103.     debug: "drawingArea"
  104.    };
  105. // View drawingArea is declared to baseView
  106.  
  107.  
  108.  
  109. theInfo := /* child of baseView */
  110.    {text: "I pity the fool who connects the dots",
  111.     viewBounds: {left: 18, top: 18, right: 218, bottom: 34},
  112.     _proto: protoStaticText,
  113.     debug: "theInfo"
  114.    };
  115.  
  116.  
  117.  
  118. wipeOut := /* child of baseView */
  119.    {text: "Erase Poly",
  120.     viewBounds: {left: 0, top: 276, right: 100, bottom: 296},
  121.     buttonClickScript:
  122.       func()    // call Erase function inside DrawingArea
  123.       begin
  124.           drawingArea:ZapArray();
  125.           SetValue(drawingArea,'icon,nil);
  126.       end,
  127.     viewJustify: 8388630,
  128.     _proto: protoTextButton,
  129.     debug: "wipeOut"
  130.    };
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138. // ---- Beginning of section for non used Layout files ----
  139.  
  140. // End of output